<template>
  <el-dialog
    title="审核"
    :close-on-click-modal="false"
    :visible.sync="visible">
    <el-form :model="dataForm"  ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="80px">
      <div style="margin-top: 20px">
   <el-form-item label="请选择：" prop="radio">
    <el-radio-group v-model="dataForm.reviewStatus" size="medium">
      <el-radio-button label="0" >待审核</el-radio-button>
      <el-radio-button label="1">审核中</el-radio-button>
      <el-radio-button label="2">审核通过</el-radio-button>
      <el-radio-button label="3">驳回</el-radio-button>
    </el-radio-group>
 </el-form-item>
 </div>
    <el-form-item label="驳回原因:" v-if="dataForm.reviewStatus==3" prop="waiguaDescribe">
      <el-input v-model="dataForm.waiguaDescribe" placeholder=""></el-input>
    </el-form-item>

    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button @click="visible = false">取消</el-button>
      <el-button type="primary" @click="dataFormSubmit()">确定</el-button>
    </span>
  </el-dialog>
</template>

<script>
  export default {
    data () {
      return {
        visible: false,
        radio: 0,
        dataForm: {
          id: 0,
          reviewStatus: '',
          waiguaDescribe: ''
        }
      }
    },
    computed: {
      userId: {
        get () { return this.$store.state.user.id }
      }
    },
    methods: {
      init (id) {
        this.dataForm.id = id || 0
        this.visible = true
        this.$nextTick(() => {
          this.$refs['dataForm'].resetFields()
          if (this.dataForm.id) {
            this.$http({
              url: this.$http.adornUrl(`/waiguagg/info/info/${this.dataForm.id}`),
              method: 'get',
              params: this.$http.adornParams()
            }).then(({data}) => {
              console.log(data)
              if (data && data.code === 0) {
                this.dataForm.reviewStatus = data.info.reviewStatus
                 this.dataForm.waiguaDescribe = data.info.waiguaDescribe
              }
            })
          }
        })
      },
      // 表单提交
      dataFormSubmit () {
        this.$refs['dataForm'].validate((valid) => {
          if (valid) {
            this.$http({
              url: this.$http.adornUrl(`/waiguagg/info/updateReview`),
              method: 'post',
              data: this.$http.adornData({
                'waiguaInfoId': this.dataForm.id || undefined,
                'reviewStatus': this.dataForm.reviewStatus
              })
            }).then(({data}) => {
              if (data && data.code === 0) {
                this.$message({
                  message: '操作成功',
                  type: 'success',
                  duration: 1500,
                  onClose: () => {
                    this.visible = false
                    this.$emit('refreshDataList')
                  }
                })
              } else {
                this.$message.error(data.msg)
              }
            })
          }
        })
      }
    }
  }
</script>
